package com.zbp.model;

import com.mybatisflex.annotation.KeyType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.Proxy;
import org.springframework.security.core.GrantedAuthority;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 用户
 *
 * @Api注释上面的是jpa|下面的是MyBatis
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Entity
@Table
@Proxy(lazy = false)
@ApiModel(value = "角色信息")
@com.mybatisflex.annotation.Table("role")
public class Role implements Serializable, GrantedAuthority {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "ID")
    @com.mybatisflex.annotation.Id(keyType = KeyType.Auto)
    private Long id;

    @Column(nullable = false, columnDefinition = "varchar(20) comment '角色名称'")
    @ApiModelProperty(value = "角色名称")
    @com.mybatisflex.annotation.Column(value = "name")
    private String name;


    @Column(nullable = false, columnDefinition = "int(1) default 0 not null comment '状态：0正常，1删除'")
    @ApiModelProperty(value = "状态")
    @com.mybatisflex.annotation.Column(value = "status")
    private int status;

    @Override
    public String getAuthority() {
        return this.name;
    }
}
